#include<iostream>
#include<math.h>
using namespace std;
int main(void){
    int x = 0;
    int cnt = 0;
    int t;
    int res = 0 ;
    while(1){
        cin >> x;
        if(x >= 0 && x <= 153){
            break;
        }
    }
    while(x){
        t = x % 2;
        if(t == 1){
            res += pow(2,cnt);
        }
        x = x / 2;
        cnt++;
    }
    cout<<res<<endl;
    return 0;
}
